package com.fz.song.mcos.controller;


import cn.hutool.core.util.RandomUtil;
import com.fz.song.mcos.entity.McUser;
import com.fz.song.mcos.enums.CodeEnum;
import com.fz.song.mcos.exceptions.McosException;
import com.fz.song.mcos.service.IMcUserCustomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 宋发准
 * @since 2021-01-25
 */
@RestController
public class McUserController {

    @Autowired
    IMcUserCustomService mcUserCustomService;


    @GetMapping("user/list")
    public List<McUser> list() throws McosException {
        int randomInt = RandomUtil.randomInt(2);
        if (randomInt == 1) {
            throw new McosException(CodeEnum.DEMO_ERROR);
        }
        return mcUserCustomService.list();
    }

}
